package com.guiwu.gteway.industryapp.GateWayInfo;

import com.guiwu.gteway.industryapp.Data.DataRepository;
import com.guiwu.gteway.industryapp.Data.MDataSource;
import com.guiwu.gteway.industryapp.Device.module.GateWay;

public class GateWayInfoPresenter implements GateWayInfoContract.Presenter{
    private GateWayInfoContract.View mView;

    public GateWayInfoPresenter(GateWayInfoContract.View mView){
        this.mView = mView;
        mView.setPresenter(this);
    }
    @Override
    public void askForShareName(String sn) {
        DataRepository.getInstance().getDeviceShareName(sn, new MDataSource.DeviceShareNameCallback() {
            @Override
            public void onDeviceINfo(GateWay gateWay) {
                mView.onGetShareName(true,gateWay,null);
            }

            @Override
            public void onDataNotAvailable(String msg) {
                mView.onGetShareName(false,null,msg);
            }
        });
    }

    @Override
    public void askForConnectType(String sn) {
        DataRepository.getInstance().getDeviceConnectType(sn, new MDataSource.DeviceConnectTypeCallback() {
            @Override
            public void onDeviceInfo(GateWay gateWay) {
                mView.onConnectType(true,gateWay,null);
            }

            @Override
            public void onDataNotAvailable(String msg) {
                mView.onConnectType(false,null,msg);
            }
        });
    }

    @Override
    public void start() {

    }
}
